/*
 * =====================================================================================
 *
 *       Filename:  genRandom.cpp
 *
 *    Description:  Generates random data to be used in training (non-character)
 *
 *        Version:  1.0
 *        Created:  07/07/12 12:48:49
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Moos Hueting (mh), mooshueting@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include <time.h>
#include "features/char_features.h"

using namespace std;
using namespace cv;

int main(int argc, char* argv[]) {
    // initialize matrix used for storing random data
    Mat randChar(10, 10, CV_8UC1, Scalar(0));
    Mat res;

    // seed random number generator
    srand(time(0));

    for (int c=0; c < 100; c++) {
        // randomly fill character
        for (int i=0; i < 10; i++) {
            for (int j=0; j < 10; j++) {
                randChar.at<unsigned char>(i, j) = 255*(rand() % 2);
            }
        }

        resize(randChar, res, Size(0,0), 10, 10, INTER_NEAREST);

        // generate features
        int rCorners = corners(res);
        float rConvexity = convexity(res);
        float rComplexity = complexity(res);
        int rDiffSegs0 = diffsegs(res, 0);
        int rDiffSegs1 = diffsegs(res, 1);
        int rEndpoints = endpoints(res);
        float rRatio = ratio(res);
        int rHoles = holes(res);
        float rAxisMean0 = axismean(res, 0);
        float rAxisMean1 = axismean(res, 1);

        // output features
        cout << "nc, " << rCorners << ", " << rConvexity << ", " << rComplexity << ", " << rDiffSegs0 << ", " << rDiffSegs1 << ", " << rEndpoints << ", " << rRatio << ", " << rHoles << ", " << rAxisMean0 << ", " << rAxisMean1 << endl;
    }


}
